﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Qiang.Geometry
{
    public interface IGeometry
    {
        
        #region 属性

        /// <summary>
        /// 图形类型
        /// </summary>
        GeometryType GeometryType { get; }

        /// <summary>
        /// 
        /// </summary>
        int Srid { get; }
        
        /// <summary>
        /// 维数。
        /// </summary>
        int Dimension { get; }

        /// <summary>
        /// 坐标集合
        /// </summary>
        IList<Coordinate> Coordinates { get; set; }

        /// <summary>
        /// 是否为空。
        /// </summary>
        bool IsEmpty { get; }

        /// <summary>
        /// 是否为简单几何图形。
        /// 简单几何图形：不存在自相切、自相交。
        /// </summary>
        bool IsSimple { get; }

        /// <summary>
        /// 图形范围
        /// </summary>
        IEnvelope Envelope { get; }


        #endregion


        #region 查询方法


        /// <summary>
        /// 在空间上，两个图形是否相等。
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Equals(IGeometry Geometry);

        /// <summary>
        /// 在空间上，两个图形是否相离。
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Disjoint(IGeometry Geometry);

        /// <summary>
        /// 在空间上，两个图形是否相交。
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Intersects(IGeometry Geometry);

        /// <summary>
        /// 在空间上，两个图形是否相交。
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Intersects(IEnvelope Envelope);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Touches(IGeometry Geometry);
        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Crosses(IGeometry Geometry);

        /// <summary>
        /// 在空间上，此图形是否在参数图形之内。
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Within(IGeometry Geometry);

        /// <summary>
        /// 在空间上，此图形是否包含参数图形。
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Contains(IGeometry Geometry);

        /// <summary>
        /// 在空间上，两个图形是否重叠。
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Overlaps(IGeometry Geometry);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        bool Relate(IGeometry Geometry);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="M"></param>
        /// <returns></returns>
        IGeometry LocateAlong(double M);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="startM"></param>
        /// <param name="endM"></param>
        /// <returns></returns>
        IGeometry LocateBetween(double startM, double endM);


        #endregion

        
        #region 分析方法


        /// <summary>
        /// 
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        double Distance(IGeometry Geometry);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="distance"></param>
        /// <returns></returns>
        IGeometry Buffer(double distance);

        /// <summary>
        /// 此图形的凸包。
        /// </summary>
        /// <returns></returns>
        IGeometry ConvexHull();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        IGeometry Intersection(IGeometry Geometry);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        IGeometry Union(IGeometry Geometry);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        IGeometry Diffrence(IGeometry Geometry);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Geometry"></param>
        /// <returns></returns>
        IGeometry SymDifference(IGeometry Geometry);


        #endregion


        #region SQL

        /// <summary>
        /// 获取WKT描述.
        /// </summary>
        /// <returns></returns>
        string AsText();

        /// <summary>
        /// 获取WKB描述.
        /// </summary>
        /// <returns></returns>
        byte[] AsBinarry();

        #endregion


        
    }
}
